input_string = input()
flag_wrong = False
dict_word = {
    'zero': 0,
    'one': 1,
    'two': 2,
    'three': 3,
    'four': 4,
    'five': 5,
    'six': 6,
    'seven': 7,
    'eight': 8,
    'nine': 9
}
list_string = input_string.split()

def find_simple_number(number):
    a = number
    b = number
    res_1 = ''
    for k in range(number):
        f = True
        for j in range(2, a):
            if a % j == 0:
                f = False
                break
        if f:
            return a
        f = True
        for j in range(2, b):
            if b % j == 0:
                f = False
                break
        if f:
            return b
        a += 1
        b -= 1


if len(list_string) > 3 or len(list_string) < 3:
    flag_wrong = True
else:
    for word in list_string:
        if word not in dict_word:
            flag_wrong = True
            break
if flag_wrong:
    print('Wrong input')
else:
    a = ''
    for word in list_string:
        a += str(dict_word[word])
    a = int(a)
    result = find_simple_number(a)
    print(result)
